package com.zhongbei.service.impl;

import com.zhongbei.mapper.BranchMapper;
import com.zhongbei.pojo.Branch;
import com.zhongbei.service.BranchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BranchServiceImpl implements BranchService {
    //    依赖注入
    @Autowired
    private BranchMapper branchMapper;

    @Override
    public int insertBranch(Branch branch) {
        int i = branchMapper.insertBranch(branch);
        return i;
    }

    @Override
    public int deleteBranch(Integer branchId) {
        int i = branchMapper.deleteBranch(branchId);
        return i;
    }

    @Override
    public int updateBranch(Branch branch) {
        int i = branchMapper.updateBranch(branch.getBranchId(), branch);
        return i;
    }

    @Override
    public List<Branch> selectBranch() {
        List<Branch> branchList = branchMapper.selectBranch();
        return branchList;
    }

    @Override
    public Branch selectBranchByBranchId(Integer branchId) {
        Branch branch = branchMapper.selectBranchByBranchId(branchId);
        return branch;
    }

    @Override
    public List<Branch> selectBranchByBranchName(String branchName) {
        List<Branch> branchListByBranchName = branchMapper.selectBranchByBranchName(branchName);
        return branchListByBranchName;
    }

    @Override
    public List<Branch> selectBranchByParentBranchId(Integer parentBranchId) {
        List<Branch> branchListByParentBranchId = branchMapper.selectBranchByParentBranchId(parentBranchId);
        return branchListByParentBranchId;
    }

}